//
//  ExplorationCycleImageTableViewCell.m
//  TestApplication
//
//  Created by Hanlingyu on 16/8/30.
//  Copyright © 2016年 ltq. All rights reserved.
//

#import "ExplorationCycleImageTableViewCell.h"
#import "LtqCycleImages.h"
#import "Masonry.h"
#import "Banner.h"
#import "UIImageView+WebCache.h"
@interface ExplorationCycleImageTableViewCell ()
<
    ltqCycleImagesDataSource,
    LtqCycleImagesCellClickedDelegate
>

@property (nonatomic, strong) LtqCycleImages *cycleImages;

@end


@implementation ExplorationCycleImageTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createView];
        
    }
    return self;
}

- (void)createView {
    
    
    
    _cycleImages = [[LtqCycleImages alloc] init];
    _cycleImages.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:_cycleImages];
    _cycleImages.dataSource = self;
    
    
    
    
}

- (void)setBannerArray:(NSArray<Banner *> *)bannerArray {
    _bannerArray = bannerArray;
    NSMutableArray *array = [NSMutableArray array];
    for (int i = 0; i < _bannerArray.count; i++) {
        NSString *imageStr = [NSString stringWithFormat:@"http://qn.zheli.io/%@", _bannerArray[i].img];
        [array addObject:imageStr];
    }
    NSString *firstImage = [array firstObject];
    NSString *lastImage = [array lastObject];
    [array insertObject:lastImage atIndex:0];
    [array addObject:firstImage];

    _cycleImages.array = array;
    
    
}

- (void)handleDataWithObject:(id)objc cell:(LtqCycleImagesCell *)cell {
    
    [cell.cycleImage sd_setImageWithURL:[NSURL URLWithString:objc]];
    
}

- (void)cellClicked:(NSIndexPath *)indexPath {
    
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    [_cycleImages mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.right.mas_equalTo(0);
    }];
    
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
